package com.tiancheng.trade.authserver.enums;

import lombok.Getter;

import java.util.Arrays;
import java.util.Optional;

/**
 * @Author: likailun
 * @Description: 用户性别
 * @Date: create in 2024/10/21 17:13
 */
@Getter
public enum UserGenderEnum {
    /**
     * 男
     */
    man(1,"男"),
    /**
     * 女
     */
    woman(2,"女"),
    /**
     * 未知
     */
    unknown(3,"未知");

    private final Integer code;
    private final String desc;

    UserGenderEnum(int code, String desc) {
        this.code=code;
        this.desc=desc;
    }

    public static Optional<UserGenderEnum> getByCode(int code){
        return Arrays.stream(UserGenderEnum.values()).filter(g->g.getCode().equals(code)).findFirst();
    }

}
